/**
 * @categoryData ：数据对象
 * */
export function createBanner(categoryData) {

    let banner = document.createElement("div");
    banner.classList.add("banner");

    let img = document.createElement("img");
    img.src = categoryData.bannerData.src;
    img.alt = categoryData.bannerData.alt;
    banner.appendChild(img);

    return banner.outerHTML;
}


//动态创建分类商品 循环
export function createSection(categoryData) {
    var html = "";

    //创建类名标题
    categoryData.categorySectionData.forEach(item1 => {
        let categorySection = document.createElement("div");
        categorySection.classList.add("category-section");

        let sectionTitle = document.createElement("h2");
        sectionTitle.classList.add("section-title");
        sectionTitle.innerHTML = `${item1.title} <a href="#" class="view-more">查看更多 &gt;</a>`
        categorySection.appendChild(sectionTitle);

        //创建item大框
        let productGrid = document.createElement("div");
        productGrid.classList.add("product-grid");


        //循环创建item
        item1.productItem.forEach(item2 => {
            let productItem = document.createElement("div");
            productItem.classList.add("product-item");
            let img = document.createElement("img");
            let p = document.createElement("p");
            img.src = item2.src;
            img.alt = item2.alt;
            p.innerHTML = item2.alt;
            productItem.appendChild(img);
            productItem.appendChild(p);
            productGrid.appendChild(productItem);
        })

        categorySection.appendChild(productGrid);

        html += categorySection.outerHTML;
    })

    return html;
}